package com.buddy.design.pattern._05strategy.pay.payport;

import com.buddy.design.pattern._05strategy.pay.MsgResult;

public abstract class Payment {
    public abstract String getName();

    public abstract double queryBalance(String uid);

    public MsgResult pay(String uid, double amount) {
        double balance = queryBalance(uid);
        if (balance < amount) {
            return new MsgResult(500, "支付失败，余额不足", balance);
        }
        return new MsgResult(200, "支付成功", balance - amount);
    }
}
